
var WindMessages = new Object();

WindMessages.createView = function(messages) {
	
	var view = new WindView;
	view.setCssClass("WindMessages");
	view.hide();
	
	view.addError = function(error) {
		var errorView = new WindView();
		errorView.setCssClass("WindMessageError");
		
		var text = "Error";
		if(error.attribute!=null && error.attribute.length>0) {
			text += " in attribute " + error.attribute;
		}
		text += ": " + error.text;
		if(error.parameters!=null && error.parameters.length>0) {
			text += " (";
			for(var i=0; i<error.parameters.length; i++) {
				text += error.parameters[i];
				if(i<error.parameters.length-1) {
					text += ","
				}
			}
			text += ")";
		}
		
		errorView.setText(text);
		
		view.addView(errorView);
		view.show();
	}
	
	view.addWarning = function(warning) {
		var warningView = new WindView();
		warningView.setCssClass("WindMessageWarning");
		warningView.setText("Warn: " + warning.text);
		view.addView(warningView);
		view.show();
	}

	view.addInfo = function(info) {
		var infoView = new WindView();
		infoView.setCssClass("WindMessageInfo");
		infoView.setText("Info: " + info.text);
		view.addView(infoView);
		view.show();
	}
	
	return view;
}